package com.grass.appointment.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.utils.GlideEngine;
import com.androidx.p013lv.base.utils.PictureStyle;
import com.grass.appointment.C2694R;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.style.PictureParameterStyle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class DynamicItemAdapter extends BaseAdapter {
    private String domain;
    private boolean isOnClick = false;
    private Context mContext;
    private List<String> mLists;

    public DynamicItemAdapter(Context context, String str, List<String> list) {
        this.mLists = list;
        this.mContext = context;
        this.domain = str;
    }

    public DynamicItemAdapter(Context context, String str) {
        this.mContext = context;
        this.domain = str;
    }

    public void setList(List<String> list) {
        this.mLists = list;
        notifyDataSetChanged();
    }

    public int getCount() {
        List<String> list = this.mLists;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    public String getItem(int i) {
        List<String> list = this.mLists;
        if (list == null) {
            return null;
        }
        return list.get(i);
    }

    public long getItemId(int i) {
        if (this.mLists == null) {
            return 0;
        }
        return (long) i;
    }

    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = LayoutInflater.from(this.mContext).inflate(C2694R.C2699layout.item_dynamic_item, viewGroup, false);
            viewHolder = new ViewHolder();
            viewHolder.iv_cover = (ImageView) view.findViewById(C2694R.C2697id.iv_cover);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        GlideUtils.loadPicWh2(this.domain + this.mLists.get(i), viewHolder.iv_cover, 600);
        if (this.isOnClick) {
            view.setOnClickListener(new View.OnClickListener() {
                /* class com.grass.appointment.adapter.DynamicItemAdapter.View$OnClickListenerC27671 */

                public void onClick(View view) {
                    ArrayList arrayList = new ArrayList();
                    Iterator it = DynamicItemAdapter.this.mLists.iterator();
                    while (it.hasNext()) {
                        LocalMedia localMedia = new LocalMedia();
                        localMedia.setPath(DynamicItemAdapter.this.domain + ((String) it.next()));
                        arrayList.add(localMedia);
                    }
                    PictureParameterStyle picturePreviewStyle = PictureStyle.getInstance(DynamicItemAdapter.this.mContext).getPicturePreviewStyle();
                    picturePreviewStyle.f1970a = false;
                    PictureSelector.create((Activity) DynamicItemAdapter.this.mContext).setPictureStyle(picturePreviewStyle).isNotPreviewDownload(false).imageEngine(GlideEngine.createGlideEngine()).openExternalPreview(i, arrayList);
                }
            });
        }
        return view;
    }

    static class ViewHolder {
        ImageView iv_cover;

        ViewHolder() {
        }
    }
}
